package cn.highedu.spring;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;

@ComponentScan("cn.highedu.spring")
public class UserTest {
    ApplicationContext context;
    @BeforeEach
    public void createContext() {
        context = new AnnotationConfigApplicationContext(UserTest.class);
    }
    @Test
    public void test1() {
        // 从Spring容器中获取UserController对象
        UserController userController = context.getBean(UserController.class);
        userController.save();
    }

}
